package com.huluobo.a2110mvpimdemo.chat;


import static android.app.Activity.RESULT_OK;

import android.content.Intent;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

import com.huluobo.a2110mvpimdemo.R;
import com.huluobo.a2110mvpimdemo.pay.PayActivity;
import com.hyphenate.easeui.modules.chat.EaseChatFragment;
import com.hyphenate.easeui.modules.chat.interfaces.IChatExtendMenu;


public class ChatFragment extends EaseChatFragment {
    @Override
    public void initView() {
        super.initView();
        IChatExtendMenu chatExtendMenu = chatLayout.getChatInputMenu().getChatExtendMenu();
        chatExtendMenu.registerMenuItem("红包", R.drawable.baseline_payment_24, 333);
    }

    @Override
    public void onChatExtendMenuItemClick(View view, int itemId) {
        super.onChatExtendMenuItemClick(view, itemId);
        if (itemId == 333) {
            //点击的是自定义的红包
            Intent intent = new Intent(getContext(), PayActivity.class);
//            Log.i("TagA", "conversationId:" + conversationId);
            intent.putExtra("conversationId", conversationId);
            startActivityForResult(intent, 777);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == 777) {
                //刷新聊天列表
                chatLayout.getChatMessageListLayout().refreshMessages();
            }
        }
    }
}